import { getRecommendList, postPooling } from '/src/api/manageEnd/mediaRecommend/recommedList'
import { handleRequestStatus } from '@/utils/uitls.js'

export default {
  methods: {
    /* 获取列表 */
    async getRecommendList(params) {
      this.tableLoading = true
      const res = await getRecommendList(params)
      // console.log('getRecommendList', res)
      if (res.data.status !== 0) {
        this.tableLoading = false
        this.tableData = []
        this.pagination.total = 0
        return
      }
      const data = res.data.data || {}
      this.tableData = Object.freeze(data.data)
      this.pagination.total = data.count || 0
      const lastUpdateTime = (data.extra && data.extra.lastUpdateTime) || ''
      this.$emit('on-lastUpdateTime', lastUpdateTime)
      this.handleTableSelect([])
      this.tableLoading = false
    },

    /* 数据入池 */
    async postPooling(params) {
      const res = await postPooling(params)
      handleRequestStatus(res, '入池', this.handleFormSubmit)
    }
  },
}
